import {
  ILoginRequest,
  ILoginResponse,
  IRefreshTokenResponse,
  IUpdatePwdRequest,
  IUpdateAvatarRequest
} from "@/types/auth";
import request from "@/utils/requests";

export const loginApi = function (query: ILoginRequest): Promise<ILoginResponse> {
  return request<ILoginResponse>(`/login`, { method: "POST", body: query });
};
export const refreshTokenApi = function (): Promise<IRefreshTokenResponse> {
  return request<IRefreshTokenResponse>(`/auth/refreshToken`, {
    method: "POST",
  });
};

export async function updatePwdApi(
  query: IUpdatePwdRequest,
): Promise<any> {
  return request(`/user/updatePwd`, {
    method: "PUT",
    body: query,
  });
}
export async function updateAvatarApi(
  query: IUpdateAvatarRequest,
): Promise<any> {
  return request(`/user/headSculpture`, {
    method: "PUT",
    body: query,
  });
}
export async function getNewVersionApi(): Promise<any> {
  return request(`/version/getNewVersion`, {
    method: "GET",
  });
}
